package com.chanyachting.emall.domain;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;

import com.chanyachting.emall.dao.AdminDAO;
import com.chanyachting.emall.domain.base.BaseAdmin;

/**
 * This is the object class that relates to the admin table.
 * Any customizations belong here.
 */
public class Admin extends BaseAdmin {

/*[CONSTRUCTOR MARKER BEGIN]*/
	public Admin () {
		super();
	}

	/**
	 * Constructor for primary key
	 */
	public Admin (java.lang.Integer _id) {
		super(_id);
		
		Admin ad=(Admin)new AdminDAO().load(Admin.class, _id);
		
		
		try {
			if(ad!=null) BeanUtils.copyProperties(this, ad);
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

/*[CONSTRUCTOR MARKER END]*/
	
	
	public static List<Admin> list(){
		
		return new AdminDAO().find("from Admin");
	}
	
	
	public boolean save(){
		
		 new AdminDAO().save(this);
		
		return true;
	}
	
	
	
	public boolean update(){

		 new AdminDAO().update(this);
		 
		 return true;
	}
	
	public boolean delete(){
		
		 new AdminDAO().delete(this);
		
		return true;
	}
	
	
}